package com.actor.testapplication.activity;

import android.os.Bundle;

import androidx.recyclerview.widget.RecyclerView;

import com.actor.testapplication.R;
import com.actor.testapplication.adapter.BirthdayAdapter;
import com.actor.testapplication.bean.BirthItem;
import com.actor.testapplication.databinding.ActivityScrollLearningBinding;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
import java.util.List;

/**
 * description: 滑动嵌套学习
 * https://www.bilibili.com/video/BV1iX4y1i7rq/?p=18
 * @author    : ldf
 * date       : 2024/7/2 on 20:39
 */
public class ScrollLearningActivity extends BaseActivity<ActivityScrollLearningBinding> {

    private final String[]         labels   = {"个性推荐", "歌单", "主播电台", "排行榜"};
//    private BaseFragmentPagerAdapter mAdapter = new BaseFragmentPagerAdapter(getSupportFragmentManager(), labels) {
//        @Override
//        public Fragment getItem(int position) {
//            return TestFragment.newInstance();
//        }
//    };
    private final BaseQuickAdapter<Object, BaseViewHolder> mAdapter = new BaseQuickAdapter<Object, BaseViewHolder>(R.layout.fragment_test) {
    @Override
    protected void convert(@NotNull BaseViewHolder holder, Object item) {
        RecyclerView recyclerView = holder.getView(R.id.recycler_view);
        List<BirthItem> items = new ArrayList<>();
        for (int i = 0; i < 20; i++) {
            BirthItem birthItem = new BirthItem();
            birthItem.name = "姓名" + i;
            birthItem.gender = i % 2 == 1;
            birthItem.chineseZodiac = "龙";
            birthItem.zodiac = "射手座";
            items.add(birthItem);
        }
        recyclerView.setAdapter(new BirthdayAdapter(items));
    }
    //p18 23:16
};

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mAdapter.addData("");
        mAdapter.addData("");
        mAdapter.addData("");
        mAdapter.addData("");
        viewBinding.viewPager.setAdapter(mAdapter);
//        viewBinding.tabLayout.setupWithViewPager(viewBinding.viewPager);
    }
}